﻿@model cloudscribe.Core.Web.ViewModels.SiteUser.ResetPasswordViewModel
@inject IStringLocalizer<CloudscribeCore> sr
@inject SiteContext siteContext

@{
    ViewData["Title"] = sr["Reset your password"];
    ViewData["BodyClass"] = "account-section reset-password";
}

<h1>@ViewData["Title"]</h1>
<form asp-controller="Account" asp-action="ResetPassword" method="post" role="form">

     @{
        if (ViewData.ModelState.IsValid && (siteContext.PwdRequireDigit || siteContext.PwdRequireLowercase || siteContext.PwdRequireNonAlpha || siteContext.PwdRequireUppercase))
        {
            <div class="mb-3">
                <ul>
                    <li>Password must be different from current password</li>
                    @if (siteContext.PwdRequireDigit) {
                    <li>@sr["Passwords must have at least one digit ('0'-'9')."]</li>
                    }

                    @if (siteContext.PwdRequireLowercase) {
                    <li>@sr["Passwords must have at least one lowercase character ('a'-'z')."]</li>
                    }

                    @if (siteContext.PwdRequireNonAlpha) {
                    <li>@sr["Passwords must have at least one non alphanumeric character"]</li>
                    }

                    @if (siteContext.PwdRequireUppercase) {
                    <li>@sr["Passwords must have at least one uppercase character ('A'-'Z')."]</li>
                    }
                </ul>
            </div>
        }
    }


    <div asp-validation-summary="All" class="text-danger"></div>
    <input asp-for="Code" type="hidden" />
    <div class="mb-3">
        <label class="form-label" asp-for="Email">@sr["Email"]</label>
        <input asp-for="Email" class="form-control" />
        <span asp-validation-for="Email" class="invalid-feedback"></span>
    </div>
    <div class="mb-3">
        <label class="form-label" asp-for="Password">@sr["Password"]</label>

        <input asp-for="Password" class="form-control" data-val="true" data-val-length=@sr["The new password must be at least {0} characters long.", siteContext.MinRequiredPasswordLength] data-val-length-max="100" data-val-length-min="@siteContext.MinRequiredPasswordLength" data-val-required="New password is required" />
        
        <span asp-validation-for="Password" class="invalid-feedback"></span>
    </div>
    <div class="mb-3">
        <label class="form-label" asp-for="ConfirmPassword">@sr["Confirm Password"]</label>
        <input asp-for="ConfirmPassword" class="form-control" />
        <span asp-validation-for="ConfirmPassword" class="invalid-feedback"></span>
    </div>
    <div class="mb-3">
        <button name="submit" type="submit" class="btn btn-primary">@sr["Reset"]</button>
    </div>
</form>
@section Scripts {
    <script src="~/cr/js/jquery.validate.min.js"></script>
    <script src="~/cr/js/jquery.validate.unobtrusive.min.js"></script>
    <script src="~/cr/js/unobtrusive-validation-bs4.min.js"></script>
}
